package com.example.nacosproviderpayment.controller;

import com.example.common.entity.Student;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author zhaoren
 * @version 1.0
 * @description 服务降级
 * @date 2020/9/5 23:01
 **/

@RestController
@RequestMapping()
public class DegradationController {

    /**
     * 测试慢调用，结合jmeter模拟多用户并发访问
     *
     * @return
     * @throws InterruptedException
     */
    @GetMapping("test")
    public String test1() throws InterruptedException {
        TimeUnit.SECONDS.sleep(1);
        return "hello ";
    }

    /**
     * 异常调用测试
     *
     * @return
     * @throws InterruptedException
     */
    @GetMapping("e")
    public String test2() throws InterruptedException {
        int a = 10 / 0;
        return "hello ";
    }
    /**
     * 异常数调用测试
     *
     * @return
     * @throws InterruptedException
     */
    @GetMapping("errorNumber")
    public String test3() throws InterruptedException {
        int a = 10 / 0;
        return "hello ";
    }


}
